package com.glodon.paas.monitor.server.biz.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.glodon.paas.monitor.server.biz.domain.MonitorAppServerEntity;
import com.glodon.paas.monitor.server.biz.mapper.MonitorAppServerMapper;
import com.glodon.paas.monitor.server.biz.service.MonitorAppServerService;
import com.glodon.paas.monitor.server.exception.MonitorException;

@Service("monitorAppServerService")
public class MonitorAppServerServiceImpl implements MonitorAppServerService {

	@Autowired
	private MonitorAppServerMapper	monitorAppServerMapper;

	@Override
	public int deleteByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"deleteByPrimaryKey appServer id is null!");
		}
		return monitorAppServerMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(MonitorAppServerEntity record) {
		if (null == record || StringUtils.isBlank(record.getIp())) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID, "insert appServer record is null!");
		}
		return monitorAppServerMapper.insert(record);
	}

	@Override
	public int insertSelective(MonitorAppServerEntity record) {
		if (null == record || StringUtils.isBlank(record.getIp())) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"insertSelective appServer record is null!");
		}
		return monitorAppServerMapper.insertSelective(record);
	}

	@Override
	public MonitorAppServerEntity selectByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"selectByPrimaryKey appServer id is null!");
		}
		return monitorAppServerMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(MonitorAppServerEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKeySelective appServer record is null!");
		}
		return monitorAppServerMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(MonitorAppServerEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKey appServer record is null!");
		}
		return monitorAppServerMapper.updateByPrimaryKey(record);
	}

}
